import request from "@/utils/request";

// 查询团队成员
export function list(userQueryVO) {
  return request({
    url: "/user/list",
    method: "post",
    data: userQueryVO,
  });
}

export function addUser(addUserForm) {
  return request({
    url: "/user/add",
    method: "post",
    data: addUserForm,
  });
}

/**
 * 实现用户登录
 * @param {*} LoginForm 
 * @returns 
 */
export function userLogin(LoginForm) {
  return request({
    url: "/user/login",
    method: "post",
    data: LoginForm,
  });
}

export function updateUser(addUserForm) {
  return request({
    url: "/user/modify",
    method: "put",
    data: addUserForm,
  });
}

export function deleteUser(id) {
  return request({
    url: "/user/delete/" + id,
    method: "delete",
  });
}

export function modifyStatus(id, status) {
  return request({
    url: "/user/status/" + id + "/" + status,
    method: "get",
  });
}

export function deleteFile(url) {
  return request({
    url: "/oss/deleteFile",
    method: "get",
    params: {
      url,
    },
  });
}

/**
 * 导出用户列表Excel
 * @param {Object} params - 查询参数（与userForm一致，无分页）
 * @returns {Promise<Blob>} - 文件流Promise
 */
// 正确的接口定义（必须包含 /user 前缀）
export function exportUserExcel(params) {
  return request({
    url: "/user/exportExcel",
    method: "POST",
    data: params,
    responseType: "blob", // 必须设置，否则无法正确接收文件流
    headers: {
      "Content-Type": "application/json",
    },
  });
}
